package com.atguigu.spring.aop.impl;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 夏焰波
 * @date 2020-08-22 17:34
 */
public class Main {

    @Test
    public void test() {
        //1. 创建Spring的IOC容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");

        //2. 从IOC容器中获取bean的实例
        ArithmeticCalculator arithmeticCalculator = ctx.getBean(ArithmeticCalculator.class);

        System.out.println(arithmeticCalculator);
        System.out.println(arithmeticCalculator.getClass().getName());

        //3. 使用bean
        int result = arithmeticCalculator.add(3, 6);
        System.out.println("result:" + result);

        result = arithmeticCalculator.div(12, 10);
        System.out.println("result:" + result);
    }
}
